package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/cookieDemo/*")
public class CookieServlet extends BaseServlet {

   /* private void test(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
     *//*
        1.创建cookie对象
        2.将Cookie添加到response对象中
        3.响应客户端


        需求:完成登录页面记住状态操作
           是否保存用户信息
      *//*
        Cookie cookieName = new Cookie("username","admin");
        //设置存活时间  一周
        cookieName.setMaxAge(0);
        //设置Cookie存储路径:设置在根路径,将来页面获取就不需要考虑存储的路径;
        cookieName.setPath("/");
        resp.addCookie(cookieName);
        resp.sendRedirect(req.getContextPath()+"/page/login.jsp");
    }*/
}
